﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Expect.Core.BaseClasses
{
    /// <summary>
    /// Row data
    /// </summary>
    public class RowData : IEnumerable<KeyValuePair<string, string>>
    {
        private Dictionary<string, string> _dico = new Dictionary<string, string>();

        /// <summary>
        /// Number of rows
        /// </summary>
        public int Count
        {
            get
            {
                return _dico.Count;
            }
        }

        /// <summary>
        /// Indexer on keys
        /// </summary>
        /// <param name="key"></param>
        /// <returns></returns>
        public string this[string key]
        {
            get
            {
                return _dico[key];
            }
        }

        internal void Add(string key, string val)
        {
            _dico.Add(key, val);
        }

        #region IEnumerable<KeyValuePair<string,string>> Members

        /// <summary>
        /// Returns an enumerator that iterates through the collection.
        /// </summary>
        /// <returns>
        /// A <see cref="T:System.Collections.Generic.IEnumerator`1"/> that can be used to iterate through the collection.
        /// </returns>
        /// <filterpriority>1</filterpriority>
        public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
        {
            return _dico.GetEnumerator();
        }

        #endregion

        #region IEnumerable Members

        /// <summary>
        /// Returns an enumerator that iterates through a collection.
        /// </summary>
        /// <returns>
        /// An <see cref="T:System.Collections.IEnumerator"/> object that can be used to iterate through the collection.
        /// </returns>
        /// <filterpriority>2</filterpriority>
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            return _dico.GetEnumerator();
        }

        #endregion
    }
}
